home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
038a
/
bas_int1.zip
/
F_EXIST.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-06-30
|
2KB
|
51 lines
'=====================================================================
'Quick Basic Forum
' Date : 26-Jun-91
' From : Mike Kelly
'Subject : If Exist (file$) then
'======================================================================
'EXIST.BAS
' $INCLUDE: 'QB.BI'
' ----------------- Standard $INCLUDE (start QB with "/L")
DECLARE FUNCTION Exist% (File$) 'Declare the Function
CLS 'Clear Screen
Search$ = "exist.bas" 'Set file to search for
IF Exist%(Search$) THEN 'If it's there then
PRINT "OK file!" ' Do this
ELSE ' or if not then
PRINT "Bad File!" ' Do this and
SYSTEM ' Quit or whatever
END IF
FUNCTION Exist% (File$)
DIM reg AS RegTypeX 'Intialize
' --------------------------- Get Current DTA address
reg.ax = &H2F00 'Function 2FH (Get current DTA)
INTERRUPTX &H21, reg, reg 'Interrupt 21
Sgmt% = reg.es 'DTA Segment
Ofst% = reg.bx 'DTA Offset
' --------------------------- Set DTA address for desired file
Buffer$ = SPACE$(43) 'Initialize Buffer
reg.ax = &H1A00 'Function 1AH (Set DTA)
reg.ds = VARSEG(Buffer$) 'Segment of Buffer
reg.dx = SADD(Buffer$) 'Offset of Buffer
INTERRUPTX &H21, reg, reg 'Interrupt 21
' --------------------------- Check if file is there
File$ = File$ + CHR$(0) 'End it with a null
reg.ax = &H4E00 'Function 4EH (Search for 1st match)
reg.cx = 103 'File attribute is *anything*
reg.ds = VARSEG(File$) 'Segment of PathFile$
reg.dx = SADD(File$) 'Offset of PathFile$
INTERRUPTX &H21, reg, reg 'Interrupt 21
result% = reg.flags AND 1 'Make results usable
' --------------------------- Restore original DTA
reg.ax = &H1A00 'Function 1AH (Set DTA)
reg.ds = Sgmt% 'Original segment
reg.dx = Ofst% 'Original offset
INTERRUPTX &H21, reg, reg 'Interrupt 21
Exist% = result% - 1 'Equate Function to result
END FUNCTION